/**
 * 重置图表尺寸
 */
const getRefreshTable = () => {
    const chartIds = ['dg-chart-1', 'cyl-tg-diqu-chart', 'dg-chart-3', 'dg-chart-4'];
    chartIds.forEach(id => {
        var loadchart = $("#"+id)
        if (dashboard.renderedChart(loadchart)) {
            var chart01 = dashboard.chartOf(loadchart);
            chart01.resize()
        }
    });

    var loadchart = $("#chart-panel-1" )
    if (dashboard.renderedChart(loadchart)) {
        var chart01 = dashboard.chartOf(loadchart);
        chart01.resize()
    }
    myChartPieResize()
    myCharBarResize()
    // location.reload();
    console.log("重置图表尺寸")
};

// 节流函数
const throttle = (func, limit) => {
    let lastFunc;
    let lastRan;
    return function () {
        const context = this;
        const args = arguments;
        if (!lastRan) {
            func.apply(context, args);
            lastRan = Date.now();
        } else {
            clearTimeout(lastFunc);
            lastFunc = setTimeout(function () {
                if ((Date.now() - lastRan) >= limit) {
                    func.apply(context, args);
                    lastRan = Date.now();
                }
            }, limit - (Date.now() - lastRan));
        }
    };
};

// 添加限流的resize事件监听，限制为每秒最多执行一次
window.addEventListener('resize', throttle(getRefreshTable, 1000));